import { instance, unwrap } from './utils'

export async function getDates() {
  const data = await instance.post<API.Res<Data[]>>('/car/washOrder/getCarServiceDayUnit')
  return unwrap(data)
}

export async function getOrder(id: string) {
  const res = await instance.post<API.Res>('/car/washOrder/getWashOrderById', null, { params: { id } })
  return unwrap(res)
}

export async function listOrder(query?: API.Req, params?: API.PageReq) {
  const res = await instance.post<API.Res<Data[]>>('/car/washOrder/getWashOrderList', query, { params })
  return unwrap(res)
}

export async function createOrder(data: API.Req) {
  const res = await instance.post<API.Res>('/car/washOrder/addWashOrder', data)
  return unwrap(res)
}

export async function payOrder(id: string) {
  const res = await instance.post<API.Res>('/car/washOrder/getPayInfo', null, { params: { id } })
  return unwrap(res)
}

export async function cancelOrder(id: string) {
  const res = await instance.post<API.Res>('/car/washOrder/cancel', null, { params: { id } })
  return unwrap(res)
}

export async function refundOrder(id: string) {
  const res = await instance.post<API.Res>('/car/washOrder/refund', null, { params: { id } })
  return unwrap(res)
}
